<?php
//消费券及领取操作

namespace App\Repositories;

use App\Models\MonitorModel;

class MonitorRepository extends BaseRepository
{
    /**
     * @param $id
     * @return mixed
     */
    public function getMonitorById ($id)
    {
        $monitor = MonitorModel::where('id', $id)
            ->select('id', 'admin_id', 'trigger_lowest_price', 'trigger_highest_price', 'trigger_times_per_day', 'status', 'monitor_every_minutes')
            ->first();
        return $monitor;
    }

    /**
     * @param $params
     * @return mixed
     */
    public function save ($params)
    {
        return $this->saveOrUpdate('MonitorModel', $params);
    }

    public function delete ($monitorId)
    {
        if ($monitorId) {
            return MonitorModel::where('id', $monitorId)
                ->delete();
        }
        return true;
    }
}
